home *** CD-ROM | disk | FTP | other *** search
- /*
- Use the 'sdes' template to define a “safe fat resource” which
- contains both 68K and PowerPC code. A safe fat resource starts
- with 68K code which is executed the first time the resource
- is called. This code determines if MixedMode is present. If
- so, a routine descriptor is moved to the beginning of the
- resource. If not, a branch instruction to the 68K portion
- of the code is placed at the beginning of the resource.
- Therefore, the first time the resource is executed, there
- is some overhead incurred. However, subsequent calls
- will be fast.
-
- Note: This template cannot currently be used for resources
- containing code with register-based calling conventions
- because the 68K code at the beginning of the resource
- uses D0, A0, and A1.
-
- */
-
- #include "MixedMode.r"
-
- #define ExtensionUPPInfo $000003C0
-
- include "EducateQuotes.Rsrc";
-
- type 'BBXT' as 'sdes';
-
- resource 'BBXT' (128, "Educate Quotes") {
- ExtensionUPPInfo, // 68K ProcInfo
- ExtensionUPPInfo, // PowerPC ProcInfo
- $$Resource("Educate/68K", 'BBXT', 128), // Specify name, type, and ID of resource
- // containing 68k code
- $$Resource("Educate/PPC", 'BBXT', 128) // Specify name, type, and ID of resource
- // containing a pef container
- };
-
- /* Safe Fat Resources */
- type 'sdes' {
- Top:
- hex string =
- $"303C A89F" // SafeFatRsrc MOVE.W #_Unimplemented, D0
- $"A746" // _GetToolBoxTrapAddress
- $"2F08" // MOVE.L A0, -(SP)
- $"303C AAFE" // MOVE.W #_MixedModeMagic, D0
- $"A746" // _GetToolBoxTrapAddress
- $"B1DF" // CMPA.L (SP)+, A0 // Is MM installed?
- $"661A" // BNE.S InstallPPCCode
- $"41FA FFEC" // Install68KCode LEA SafeFatRsrc, A0
- $"30FC 6000" // MOVE.W #$6000, (A0)+ // Generate a BRA instruction
- $"43FA 001E" // LEA FatRD, A1
- $"2029 0014" // MOVE.L 20(A1), D0 // Get 68K code offset
- $"5580" // SUBQ.L #2, D0
- $"3080" // MOVE.W D0, (A0) // Fill in the second word of the BRA
- $"7001 A198" // _FlushInstructionCache
- $"60D4" // BRA.S SafeFatRsrc
- $"43FA FFD2" // InstallPPCCode LEA SafeFatRsrc, A1
- $"41FA 0008" // LEA FatRD, A0
- $"7034" // MOVE.L #52, D0
- $"A02E" // _BlockMove // Move R.D. to top of rsrc
- $"60C6"; // BRA SafeFatRsrc
- // FatRD // The fat routine descriptor follows
-
- /* Routine Descriptor */
- GoMixedModeTrapType = _MixedModeMagic;
- VersionType = kRoutineDescriptorVersion;
- fill bit [7];
- SelectorsAreIndexableType = FALSE;
- Reserved1Type;
- Reserved2Type;
- SelectorInfoType = 0;
- RoutineCountType = 1;
-
- /* Routine Record */
- ProcInfoType;
- Reserved3Type;
- ISAType = kM68kISA;
- fill bit [11];
- RoutineIsDispatchedDefaultType = FALSE;
- DontPassSelectorType = FALSE;
- UseNativeISAType = TRUE;
- FragmentNeedsPreparingType = FALSE;
- ProcDescriptorIsRelativeType = TRUE;
- ProcDescriptorType = (BeginningOf68KCode-Top) / 8;
- Reserved4Type;
- SelectorType = 0;
-
- /* PowerPC Routine Record 1 */
- ProcInfoType;
- Reserved3Type;
- ISAType = kPowerPCISA;
- fill bit [11];
- RoutineIsDispatchedDefaultType = FALSE;
- DontPassSelectorType = FALSE;
- UseNativeISAType = TRUE;
- FragmentNeedsPreparingType = TRUE;
- ProcDescriptorIsRelativeType = TRUE;
- ProcDescriptorType = (BeginningOfPowerPCCode-Top) / 8;
- Reserved4Type;
- SelectorType = 0;
- Align LONG;
-
- BeginningOf68KCode:
- hex string; // The 68k code starts here
-
- Align LONG;
-
- BeginningOfPowerPCCode:
- hex string; // The PEF container starts here
- };
-